package com.itxx.io;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

public class IoDemo {
    public static void main(String[] args) throws UnsupportedEncodingException {
        String s = "烧烤";
        //默认码表 utf-8
        byte[] bytes = s.getBytes();
        System.out.println("按照默认(utf-8)码表方式:" + Arrays.toString(bytes));
        //按照GBk码表
        byte[] gbks = s.getBytes("gbk");
        System.out.println("按照gbk码表方式:" + Arrays.toString(gbks));

        //默认解码码表解码
        byte[] b1 = {-25, -125, -89, -25, -125, -92};
        String s1 = new String(b1);
        System.out.println("按照默认码表解码为:" + s1);
        //按照gbk码表解码
        String s2 = new String(b1, "gbk");
        System.out.println("按照gbk码表解码为:" + s2);


        //按照gbk码表解码
        byte[] b = {-54, -19, -58, -84};
        String gbk = new String(b, "gbk");
        System.out.println("按照gbk码表解码为:" + gbk);

    }
}
